package com.mstore.dao;

import java.util.List;

import com.mstore.pojo.IPAuthority;

public class IPAuthorityDao extends SuperDao {

	/**
	 * 
	 *根据ip、create_time查询ip访问记录
	 */
	public List<Object> watchIPAuthority(IPAuthority ipAuthority) {
		String hql = "from IPAuthority where ip = ? and createTime between ? and ?";
		Object[] values = new Object[] { ipAuthority.getIp(), ipAuthority.getBeginTime(), ipAuthority.getEndTime() };
		return super.getObject(hql, values);
	}

	/**
	 * 
	 *  保存IP访问记录
	 */
	public void saveIPAuthority(IPAuthority ipAuthority) {
		super.save(ipAuthority);
	}

	/**
	 * 
	 * 修改IP访问次数
	 */
	public void modifyIPAuthorityCount(IPAuthority ipAuthority) {
		/*String sql = "update b_ip_authority set visit_count=" + ipAuthority.getVisitCount()
				+ " WHERE id = " + ipAuthority.getId();
		super.executeUpdate(sql);*/
		
		StringBuilder sb=new StringBuilder();
		sb.append("update b_ip_authority set visit_count=");
		sb.append(ipAuthority.getVisitCount());
		sb.append(" WHERE id = ");
		sb.append(ipAuthority.getId());
		super.executeUpdate(sb.toString());
	}

}
